diff options
| author | Joe Carstairs <65492573+Sycamost@users.noreply.github.com> | 2023-12-17 14:06:23 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-17 14:06:23 +0000 |
| commit | fe9844b8eac1daf3eeedf141e223d0733c892fa0 (patch) | |
| tree | e89ac30c35b3cd518c563db965fd44197cf0a6a0 /src/pages/[locale]/news/[...slug].astro | |
| parent | 250152cc1b6a67bd18f4b211856fa98ec06d8eda (diff) | |
Update production from staging (#48)
* Edit README (#28)
* Corrects Lallans instructions
* Adds instructions for adding a Scotsoun release
* Documents infrastructure
* Better contribution guidance
* Update README (#29)
* Updates references to branch names in README
* ESLint ignores Markdown
* Documents Coding Style
* Specifies upstream branch in README where salient
* Fixes Sangschaw winners list in Eiks 30 (#35)
* Fixes Sangschaw winners list in Eiks 30 (#36)
* Fixes Sangschaw winners list in Eiks 30 (#38)
* Eiks 31 (#41)
* Eiks 31
* Prettier dl's
* Prettier headings
---------
Co-authored-by: Joe Carstairs <jcarstairs@scottlogic.com>
* Reorder news (#42)
* Reslugs news items
* Fixes typo in getMostRecentNewsItem()
* Fixes typo in newUtils.getDate()
* Sorts news index from most recent to oldest
* Eiks 31 fixes (#43)
* Eiks 31 fixes
* Improves list styling
* Links to Leid title track on YouTube (#45)
* Eiks 31 fixes (#47)
* Links to Leid title track on YouTube
* Corrects Sangschaw pricing
* Update production (#37) (#49)
* Edit README (#28)
* Corrects Lallans instructions
* Adds instructions for adding a Scotsoun release
* Documents infrastructure
* Better contribution guidance
* Update README (#29)
* Updates references to branch names in README
* ESLint ignores Markdown
* Documents Coding Style
* Specifies upstream branch in README where salient
* Fixes Sangschaw winners list in Eiks 30 (#35)
* Fixes Sangschaw winners list in Eiks 30 (#36)
* Fixes Sangschaw winners list in Eiks 30 (#38)
---------
Co-authored-by: Joe Carstairs <jcarstairs@scottlogic.com>
Diffstat (limited to 'src/pages/[locale]/news/[...slug].astro')
| -rw-r--r-- | src/pages/[locale]/news/[...slug].astro | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/src/pages/[locale]/news/[...slug].astro b/src/pages/[locale]/news/[...slug].astro index e3b8b36..a24e65a 100644 --- a/src/pages/[locale]/news/[...slug].astro +++ b/src/pages/[locale]/news/[...slug].astro @@ -1,28 +1,13 @@ --- -import locales from '$i18n/locales'; import Article from '$layouts/Article.astro'; -import type Locale from '$types/Locale'; -import { CollectionEntry, getCollection } from 'astro:content'; +import { getCollection } from 'astro:content'; +import { getLocale, getSlug } from '$lib/newsUtils'; export async function getStaticPaths() { - function localeFromSlug(slug: CollectionEntry<'news'>['slug']): Locale | undefined { - const lowerCaseLocale = new RegExp(`^(${locales.map((l) => l.toLocaleLowerCase()).join('|')})`); - const matchedLowerCaseLocale = slug.match(lowerCaseLocale)?.[1]; - switch (matchedLowerCaseLocale) { - case 'sco': - return 'sco'; - case 'en-gb': - return 'en-GB'; - default: - console.warn('Could not find locale in slug %s', slug); - return undefined; - } - } - return (await getCollection('news')).map((entry) => ({ params: { - slug: entry.slug.replace('/', '-'), - locale: localeFromSlug(entry.slug), + slug: getSlug(entry), + locale: getLocale(entry), }, props: { entry }, })); |
